package ngames.com.sushitv.Fragment;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import java.util.ArrayList;

import ngames.com.sushitv.R;
import ngames.com.sushitv.temp.Adapter.MyPagerAdapter;
import ngames.com.sushitv.view.Indicator;

/**
 * Created by edmond on 16-7-26.
 */
public class SubscriptionFragment extends Fragment{
    private View view;

    private ArrayList<Fragment> fragments;
    private MyPagerAdapter adapter;
    private Indicator indicator;
    private ViewPager viewPager;

    private AnimeFragment animeFragment;
    private FollowingFragment followingFragment;
    private TagsFragment tagsFragment;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        view = inflater.inflate(R.layout.fragment_subscription,container,false);
        Log.d("Sub","1111");
        init();

        return view;
    }

    private void init(){
        indicator = (Indicator) view.findViewById(R.id.indicator);
        viewPager = (ViewPager) view.findViewById(R.id.viewPager);
        viewPager.setOffscreenPageLimit(2);

        fragments = new ArrayList<>();

        animeFragment = new AnimeFragment();
        followingFragment = new FollowingFragment();
        tagsFragment = new TagsFragment();

        fragments.add(animeFragment);
        fragments.add(followingFragment);
        fragments.add(tagsFragment);

        adapter = new MyPagerAdapter(getChildFragmentManager(),fragments);
        viewPager.setAdapter(adapter);
        indicator.setViewPager(viewPager,0);
        Log.d("Sub","init");
    }
}
